import 'package:flutter/material.dart';

import '../../common/index.dart';
import '../../tools/index.dart';
import '../models/tu_chong_model.dart';
import '../routers/index.dart';

class ItemLessWidget extends BaseLessWidget {
  const ItemLessWidget({
    super.key,
    required this.item,
    this.type = 0,
  });

  // --------- 公开属性  --------- //
  // 传入数据
  final TuChongItem item;

  final int type;
  // --------- 私有属性  --------- //

  // --------- 生命周期  --------- //

  // --------- 构建UI  --------- //
  @override
  Widget createBody({
    required BuildContext context,
    BoxConstraints? constraints,
  }) {
    Widget body = Column(
      children: [
        createItmeHeaderImageWidget(),
      ],
    );
    body = GestureDetector(
      onTap: () {
        tapOrderDetail();
      },
      child: body,
    );
    return body;
  }

  createItmeHeaderImageWidget() {
    Widget body = Image.network(
      item.heaerImgModel?.url ?? "",
      fit: BoxFit.cover,
      width: item.heaerImgModel?.size?.width,
      height: item.heaerImgModel?.size?.height,
    );

    return body;
  }
  // --------- 触发事件  --------- //

  tapOrderDetail() {
    var url = type == 0 ? EgRouterPath.egDetailV : EgRouterPath.egDetailV;
    currentToPage(name: url, arguments: item);
  }
}
